<?php
namespace app\admin\controller;
use think\Db;
use think\Controller;
use think\Session;
class Room extends Base{
    //显示角色列表
    //sql:select i.id,name,tele,area,building,dortext,domtime,content from info i join dorm d where i.dormid=d.id and rid=1 and status=0 and destatus=0 order by addtime desc

    public function index(){
		$nets=Db::name("info i")->join("dorm d","i.dormid=d.id")->field("i.id,name,tele,area,building,dortext,domtime,addtime,content,status")->where("rid",2)->where("status",0)->where("destatus",0)->order("addtime desc")->select();
		$this->assign("nets",$nets);
		Session::set("actions",'room/index');
		return $this->fetch();
		
	}
	public function editinfo()
	{
		$id=input('id');
		$status=input('status');
		$data=[
			"status"=>!$status,
		];
		$res = Db::name("info")->where("id",$id)->update($data);		
		$this->success('修改成功','room/index');
	}
	public function delinfo(){
		$id=input('id');
		$data=[
			"destatus"=>1,
		];
		$res = Db::name("info")->where("id",$id)->update($data);	
		if($res)
		$this->success('删除成功','room/index');	
		else
		$this->error('修改失败');
	}
	
}